package com.psl.action.frameAction;

import com.psl.model.userlogin;
import com.psl.services.frame.accesspage;
import com.psl.services.work.list.halfProductServices;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class accessmodule {
    private String moduleName;
    private String groupName;
    private String page;
    private int position_id;

    public String getModuleName() {
        return this.moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getGroupName() {
        return this.groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getPage() {
        return this.page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public int getPosition_id() {
        return this.position_id;
    }

    public void setPosition_id(int position_id) {
        this.position_id = position_id;
    }

    public String execute() {
        HttpServletRequest request = ServletActionContext.getRequest();
        String groupId = request.getParameter("groupId");
        String moduleId = request.getParameter("moduleId");
        if(groupId!=null &&moduleId==null){
            return "page";
        }
        if (groupId != null && moduleId != null) {
            accesspage ap = new accesspage();
            ap.querypage(Integer.parseInt(groupId),Integer.parseInt(moduleId));
            return "page";
        } else {
            HttpSession session = ServletActionContext.getRequest().getSession();
            userlogin userinfo = (userlogin) session.getAttribute("user");
            accesspage ap = new accesspage();
            ap.queryAllGroup(userinfo.getPosition_id());
            halfProductServices hps = new halfProductServices();
            hps.querystatuswait();
            return "list";
        }
    }
}
